//
//  ViewController.m
//  ProgressViewDemo
//
//  Created by zhanghua0221 on 16/11/9.
//  Copyright © 2016年 zhanghua0221. All rights reserved.
//

#import "ViewController.h"
#import "CircleProgressView.h"

@interface ViewController ()
@property (nonatomic, strong) CircleProgressView *circleProgress;
@property (nonatomic, strong) NSTimer *timer;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.circleProgress];
    
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(progressTimer:) userInfo:nil repeats:YES];

}

- (void)progressTimer:(NSTimer *)timer
{
    self.circleProgress.percent += 0.05;
    self.circleProgress.centerLabel.text = [NSString stringWithFormat:@"%.02f%%", self.circleProgress.percent*100];

    if(self.circleProgress.percent > 1)
    {
        [self.timer invalidate];
    }
}
- (CircleProgressView *)circleProgress
{
    if(!_circleProgress)
    {
        _circleProgress = [[CircleProgressView alloc] initWithFrame:CGRectMake(50, 80, 80, 80)];
        _circleProgress.backgroundColor = [UIColor clearColor];
    }
    return _circleProgress;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
